home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / INCLUDE / SETJMP.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  138 lines

  1. /* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /*
  20.  *    ANSI Standard: 4.6 NON-LOCAL JUMPS <setjmp.h>
  21.  */
  22.  
  23. #ifndef    _SETJMP_H
  24.  
  25. #define    _SETJMP_H    1
  26. #include <features.h>
  27.  
  28. __BEGIN_DECLS
  29.  
  30. /* Get the machine-dependent definition of `__jmp_buf'.  */
  31. #include <jmp_buf.h>
  32.  
  33.  
  34. #ifdef    __USE_POSIX
  35. #define    __need_sigset_t
  36. #include <signal.h>
  37.  
  38. /* Calling environment, plus possibly a saved signal mask.  */
  39. typedef struct __sigjmp_buf_base
  40.   {
  41.     __jmp_buf __jmpbuf;        /* Calling environment.  */
  42.     int __mask_was_saved;    /* Saved the signal mask?  */
  43.     sigset_t __saved_mask;    /* Saved signal mask.  */
  44. #ifdef __SVR4_I386_ABI_L1__
  45.     unsigned long pad1[116];
  46. #endif /* __SVR4_I386_ABI_L1__ */
  47.   } sigjmp_buf[1];
  48.  
  49. /* Store the calling environment in ENV, also saving the
  50.    signal mask if SAVEMASK is nonzero.  Return 0.  */
  51. extern void __sigjmp_save __P ((sigjmp_buf __env, int __savemask));
  52. #ifdef __GNUC__
  53. #define    sigsetjmp(env, savemask) \
  54.   __extension__                                      \
  55.   ({ __typeof ((*((sigjmp_buf *) 0))[0]) *__e = (env);                  \
  56.      __sigjmp_save (__e, (savemask));                          \
  57.      __setjmp (__e[0].__jmpbuf); })
  58. #else
  59. /* Not strictly POSIX-compliant, because it evaluates ENV more than once.  */
  60. #define    sigsetjmp(env, savemask) \
  61.   (__sigjmp_save ((env), (savemask)), __setjmp ((env)[0].__jmpbuf))
  62. #endif
  63.  
  64.  
  65. /* Jump to the environment saved in ENV, making the
  66.    sigsetjmp call there return VAL, or 1 if VAL is 0.
  67.    Restore the signal mask if that sigsetjmp call saved it.  */
  68. extern __NORETURN void siglongjmp __P ((sigjmp_buf __env,
  69.                     int __val)) __NORETURN2;
  70. #endif /* Use POSIX.  */
  71.  
  72.  
  73. #ifdef    __FAVOR_BSD
  74.  
  75. /* BSD defines `setjmp' and `longjmp' to save and restore the set of
  76.    blocked signals.  For this, `jmp_buf' must be what POSIX calls
  77.    `sigjmp_buf', which includes that information.  */
  78. typedef sigjmp_buf jmp_buf;
  79.  
  80. #else /* Don't favor BSD.  */
  81.  
  82. /* A `jmp_buf' really is a `jmp_buf'.  Oh boy.  */
  83. typedef __jmp_buf jmp_buf;
  84.  
  85. #endif /* Favor BSD.  */
  86.  
  87.  
  88. /* Jump to the environment saved in ENV, making the
  89.    setjmp call there return VAL, or 1 if VAL is 0.  */
  90. extern __NORETURN void __longjmp __P ((__jmp_buf __env,
  91.                        int __val)) __NORETURN2;
  92. extern __NORETURN void longjmp __P ((jmp_buf __env,
  93.                      int __val)) __NORETURN2;
  94.  
  95. /* Set ENV to the current position and return 0.  */
  96. extern int __setjmp __P ((__jmp_buf __env));
  97. /* The ANSI C standard says `setjmp' is a macro.  */
  98. #define    setjmp(env)    __setjmp (env)
  99.  
  100.  
  101. #ifdef    __USE_BSD
  102. extern void __NORETURN _longjmp __P ((jmp_buf __env,
  103.                       int __val)) __NORETURN2;
  104. #endif /* Use BSD.  */
  105.  
  106. #ifdef    __FAVOR_BSD
  107.  
  108. /* We are in the mode in which `setjmp' and `longjmp' save and restore
  109.    the signal mask, and `jmp_buf' is `sigjmp_buf'.  */
  110.  
  111. #undef    setjmp
  112. #undef    longjmp
  113.  
  114. #define    setjmp(env)        sigsetjmp ((env), 1)
  115.  
  116. #define    longjmp(env, val)    siglongjmp ((env), (val))
  117.  
  118. #define    _setjmp(env)        sigsetjmp ((env), 0)
  119.  
  120. #else    /* Don't favor BSD.  */
  121.  
  122. /* `setjmp' and `_setjmp' are the same.  */
  123. #define    _setjmp(env)        setjmp (env)
  124.  
  125. /* `longjmp' and `_longjmp' are the same.  */
  126. #define    _longjmp(env, val)    longjmp ((env), (val))
  127.  
  128. #endif /* Favor BSD.  */
  129.  
  130. #ifdef __SVR4_I386_ABI_L1__
  131. #define _SIGJBLEN    (sizeof(sigjmp_buf)/sizeof(int))
  132. #define _JBLEN        (sizeof(jmp_buf)/sizeof(int))
  133. #endif
  134.  
  135. __END_DECLS
  136.  
  137. #endif /* setjmp.h  */
  138.